package com.zhao.controller;

import com.zhao.feign.ProductFeign;
import com.zhao.pojo.Product;
import com.zhao.pojo.User;
import lombok.extern.slf4j.Slf4j;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RequestMapping("user")
@Slf4j
@RestController
public class UserController {

    @Autowired
    private ProductFeign productFeign;

    @GetMapping("getUserInfo/{id}")
    public User getUserInfo(@PathVariable("id") String id) {
        Product product = productFeign.getProduct(id);
        User user = new User("u01", "张三", product);
        log.info("用户：{}, 持有产品：{}", user, product);
        return user;
    }
}
